package com.example.sls.controller.logistics;

import com.example.sls.pojo.logistics.EquipmentDiscard;
import com.example.sls.service.intserfaces.logistics.EquipmentDiscardService;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 设备报废记录表(EquipmentDiscard)表控制层
 *
 * @author 蓝江富
 * @since 2024-06-19 13:23:44
 */
@RestController
@RequestMapping("logistics/equipmentDiscard")
public class EquipmentDiscardController {
  @Autowired
  EquipmentDiscardService equipmentDiscardService;

  @InitBinder
  public void initDateFormate(WebDataBinder dataBinder) {
    dataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
  }
  @GetMapping("queryById")
  EquipmentDiscard queryById(Integer id) {
    return equipmentDiscardService.queryById(id);
  }

  @GetMapping("queryAllByLimit")
  List<EquipmentDiscard> queryAllByLimit(EquipmentDiscard equipmentDiscard, Integer pageSize, Integer offset) {
    return equipmentDiscardService.queryAllByLimit(equipmentDiscard, pageSize, offset);
  }

  @GetMapping("queryAll")
  List<EquipmentDiscard> queryAll() {
    return equipmentDiscardService.queryAllByLimit(new EquipmentDiscard(), 999999, 0);
  }

  @GetMapping("count")
  long count() {
    return equipmentDiscardService.count();
  }

  @GetMapping("insert")
  int insert(EquipmentDiscard equipmentDiscard) {
    return equipmentDiscardService.insert(equipmentDiscard);
  }

  @GetMapping("update")
  int update(EquipmentDiscard equipmentDiscard) {
    return equipmentDiscardService.update(equipmentDiscard);
  }

  @GetMapping("deleteById")
  int deleteById(Integer id) {
    return equipmentDiscardService.deleteById(id);
  }
}

